home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir34 / 2boot.zip / BOOT.BAS next >
BASIC Source File  |  1994-01-13  |  5KB  |  167 lines

  1. '********************************BOOT.BAS********************************
  2. 'A teeny program that will print what is your boot drive is!
  3. '
  4. 'Up until now the only way I could even close to knowing what the
  5. 'boot disk was by querying:
  6. '
  7. 'A$ = ENVIRON$("COMSPEC")
  8. 'if the variable is NOT null
  9. 'IF LEN(A$) THEN BootDrive$ = LEFT$(A$,2)
  10. 'PRINT "Your Boot Drive is: "; BootDrive$
  11. '
  12. 'The Function ENVIRON$ -as used above- finds out where COMMAND.COM
  13. 'is loaded from AND ASSumes that this is the same as the boot drive.
  14. '
  15. 'Well, that was not good enough as some folk use the SHELL command
  16. 'in the CONFIG.SYS file to move COMMAND.COM around
  17. '(Well... I know, =I= do!)
  18. '
  19. 'BOOT.BAS was =decoded= from "Norton's PC Programmer's Bible",
  20. 'Microsoft Press 1993. T'was Not easy....
  21. 'If you don't like to head scratch and pot around a lot, don't buy "Norton,"
  22. 'as it is written for assembly and "C" cats. The 615 page book has little
  23. 'QuickBASIC code or explanation on how to CALL INTERRUPT.
  24. '
  25. 'Ethan Winer's book "BASIC Techiques and Utilities" 1991 is the best
  26. 'place to "code surf" for QuickBASIC information on CALL INTERRUPT.
  27. '
  28. '1/13/94
  29. '
  30. 'John De Palma on CompuServe 76076,571
  31. '================================END TEXT===================================
  32. '
  33. 'Declarations, Routines, include files
  34. DEFINT A-Z
  35. DECLARE SUB LocateIt (Row%, text$)
  36. DECLARE SUB ColorIt (Fgd%, Bkg%)
  37. DECLARE SUB DrawBox (title$, text$)
  38. DECLARE FUNCTION DosVersion$ ()
  39. '
  40. 'Next, one User Defined TYPE for -both- CALL INTERRUPT and CALL INTERRUPTX
  41. '
  42. 'QuickBASIC can use 10 of the 14 Registers (Built-in integer variables)
  43.  
  44. TYPE RegType
  45.      ax        AS INTEGER               'Accumulator       Register
  46.      bx        AS INTEGER               'Base                 "
  47.      cx        AS INTEGER               'Count                "
  48.      dx        AS INTEGER               'Data                 "
  49.      bp        AS INTEGER               'Base Pointer         "
  50.      si        AS INTEGER               'Source Index         "
  51.      di        AS INTEGER               'Destination Index    "
  52.      flags     AS INTEGER               'Flags                "
  53.      ds        AS INTEGER               'Data Segment         "
  54.      es        AS INTEGER               'Extra Segment        "
  55. END TYPE
  56.  
  57. 'note we -have to- use "InRegs" and "OutRegs" or can't compile this
  58. DECLARE SUB Interrupt (intnum%, InRegs AS RegType, OutRegs AS RegType)
  59.  
  60. 'executable code begins here
  61.  
  62. 'old fashioned FUNCTION that is global and fast is next
  63. DEF FnCenter (text$) = 41 - (LEN(text$) \ 2)
  64. COLOR 15, 1
  65. CLS
  66.  
  67. 'trap a DOS version that would give us the wrong answer.
  68. IF VAL(DosVersion$) < 4 THEN
  69.    
  70.     BEEP
  71.     text$ = "Your MS-DOS Version is: " + DosVersion$
  72.     CALL LocateIt(4, text$)
  73.    
  74.     text$ = "This program requires a DOS Version of 4.0 or higher"
  75.     CALL LocateIt(6, text$)
  76.    
  77.     text$ = "Sorry... have to END, press any key."
  78.     CALL LocateIt(8, text$)
  79.    
  80.     SLEEP
  81.     WHILE INKEY$ <> "": WEND
  82.     END
  83. END IF
  84. 'STOP
  85. DIM Regs AS RegType
  86. Regs.ax = &H3305                       'AH = 33, AL = 05
  87. CALL Interrupt(&H21, Regs, Regs)       'use MS-DOS main interrupt &H21
  88.   
  89. BootDrive% = Regs.dx MOD 256           'Drive is in DL (the low byte of DX)
  90.                                        '1 = A
  91.                                        '2 = B
  92.                                        '3 = C  etc...
  93. title$ = "Boot Drive"
  94. text$ = CHR$(BootDrive% + 64) + ":"
  95. CALL DrawBox(title$, text$)
  96. text$ = "John De Palma on CompuServe 76076,571"
  97. CALL ColorIt(11, 0)
  98. CALL LocateIt(22, text$)
  99. CALL ColorIt(7, 0)
  100.  
  101. SUB ColorIt (Fgd, Bkg)
  102. COLOR Fgd, Bkg
  103. END SUB
  104.  
  105. SUB DosInt (ax%, bx%, cx%, dx%)
  106. DIM Regs AS RegType
  107.  
  108. Regs.ax = ax%
  109. Regs.bx = bx%
  110. Regs.cx = cx%
  111. Regs.dx = dx%
  112.  
  113. CALL Interrupt(&H21, Regs, Regs)
  114.  
  115. ax% = Regs.ax
  116. bx% = Regs.bx
  117. cx% = Regs.cx
  118. dx% = Regs.dx
  119.             
  120. END SUB
  121.  
  122. FUNCTION DosVersion$ STATIC
  123.     DIM Regs AS RegType
  124.    
  125.     Regs.ax = &H3001
  126.     CALL Interrupt(&H21, Regs, Regs)
  127.     Major% = Regs.ax MOD 256            'AL
  128.     Minor! = Regs.ax \ 256              'AH
  129.     VersionFlag% = Regs.bx \ 256        'BH  
  130.         IF Minor% = 0 THEN
  131.             DosVersion$ = STR$(Major%) + ".00"
  132.         ELSE
  133.             DosVersion$ = STR$(Major%) + STR$(Minor! / 100!)
  134.         END IF
  135.     
  136.      'to test this function, uncomment the next line
  137.      'DosVersion$ = "3.30"
  138. END FUNCTION
  139.  
  140. SUB DrawBox (title$, text$)
  141.    
  142.     wide% = LEN(title$)
  143.    
  144.     Work$ = "╓" + STRING$(wide% + 2, 196) + "╖"
  145.     CALL ColorIt(15, 4)
  146.     CALL LocateIt(10, Work$)
  147.    
  148.     Work2$ = "║ " + title$ + " ║"
  149.     CALL LocateIt(11, Work2$)
  150.  
  151.     Work3$ = "║" + SPACE$(wide% + 2) + "║"
  152.     CALL LocateIt(12, Work3$)
  153.     CALL ColorIt(11, 0)
  154.     CALL LocateIt(12, text$)
  155.     CALL ColorIt(15, 4)
  156.     Work4$ = "╙" + STRING$(wide% + 2, 196) + "╜"
  157.     CALL LocateIt(13, Work4$)
  158.  
  159.  
  160. END SUB
  161.  
  162. SUB LocateIt (Row%, text$)
  163. LOCATE Row%, FnCenter(text$)
  164. PRINT text$;
  165. END SUB
  166.  
  167.